// import 'dart:html';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:graduation_project/common/global.dart';
import 'package:graduation_project/menu_bar/search/search_state_no.dart';
import 'package:graduation_project/menu_bar/search/search_state_yes.dart';
// import 'package:flutter_search_bars/flutter_search_bars.dart';

class search_bar extends StatefulWidget {
  const search_bar({Key key}) : super(key: key);

  @override
  State<search_bar> createState() => _search_barState();
}

class _search_barState extends State<search_bar> {
  // String search_value;

  // 搜索状态 用于查看搜索框是否是搜索状态
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    search_state = 0;
    search_value.text = null;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(
        // preferredSize: Size.fromHeight(search_state != 0 ? 220 : 50),
        preferredSize: Size.fromHeight(50),

        child: AppBar(
          // title: Text('123'),
          titleSpacing: 0, //清除title左右padding，默认情况下会有一定的padding距离
          backgroundColor: Colors.white,
          // textTheme: ,
          // flexibleSpace:
          actions: [
            Container(
              width: 340,
              margin: EdgeInsets.only(left: 10, top: 10, bottom: 10),
              child: TextField(
                onChanged: (value) {
                  setState(() {
                    search_state = 0;
                  });
                },
                onEditingComplete: () {
                  print(search_value.text);
                  setState(() {
                    search_state = 1;
                  });
                },
                // enabled: true,
                controller: search_value,
                decoration: InputDecoration(
                    prefixIcon: Icon(Icons.search),
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10)))),
              ),
            ),
            Expanded(child: SizedBox()),
            InkWell(
              onTap: () {
                Navigator.of(context).pop();
              },
              child: Container(
                  margin: EdgeInsets.only(top: 15, right: 20),
                  child: Text(
                    '取消',
                    style: TextStyle(color: Colors.black87),
                  )),
            )
          ],

          automaticallyImplyLeading: false,
        ),
      ),
      body: search_state == 0 ? search_state_no() : search_state_yes(),
    );
  }
}
